<template>
    <div>
        <el-form class="login-container" label-position="left" label-width="0px" style="width:350px;margin:0 auto;">
            <h3 class="login_title">系统登录</h3>
            <el-form-item>
                <el-input type="text" v-model="loginForm.username" auto-complete="off" placeholder="账号"></el-input>
            </el-form-item>

            <el-form-item>
            <el-input type="password" v-model="loginForm.password" auto-complete="off" placeholder="密码"></el-input>
            </el-form-item>

            <el-form-item style="width: 100%">
            <el-button type="primary" style="width: 100%;background: #505458;border: none" @click="login">登录</el-button>
            </el-form-item>
        </el-form>
        {{loginForm}}
    </div>
</template>

<script>
import axios from 'axios'

export default {
    data(){
        return {
            loginForm:{
                username:'',
                password:''
            },

        }
    },
    methods:{
        login(){
            axios.get("http://localhost:3312/user/login",{
                params:{
                    username:this.loginForm.username,
                    password:this.loginForm.password
                }
            }).then((resp)=>{
                if(resp.data.success==true){
                    alert(resp.data.message)
                    this.$router.push('/mainCrud')

                }else{
                    alert("用户名或密码错误")
                }
            })
            
        }
    }
}
</script>